<template>
<p class="out">
  <span class="hello">{{username}}</span>
  <a @click="Out()">退出</a>
</p>

  
</template>

<script>
import { loginOut } from "@/api/index.js";
import { ElMessage } from "element-plus";
export default {
  name: "LoginOut",
  props: ['username'],
  data() {
    return {
    };
  },
  created(){
    console.log()
  },
  methods: {
    Out() {
      var that = this;
      loginOut()
        .then(function (res) {
          if (res.code == 1) {
            sessionStorage.clear();
            ElMessage.success("退出成功！");
            that.$router.push({ path: "/login" });
          }
        })
        .catch(function (error) {});
    },
  },
};
</script>

<style scoped>
a:hover {
  cursor: pointer;
  color: #409eff;
}
.out{
  line-height: 60px;
}
.out .hello{
  margin-right: 10px;
}
</style>
